﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QLXuongCNTT.Object;
using QLXuongCNTT.ControlLayers;

namespace QLXuongCNTT
{
    public partial class frmDMTO : Form
    {
        public frmDMTO()
        {
            InitializeComponent();
        }
        ctrlDMto dmto_ctr = new ctrlDMto();

        private void frmDMTO_Load(object sender, EventArgs e)
        {
            dataGridView1.AutoGenerateColumns = false;
            bindingSource1.DataSource =dmto_ctr.getDMto();
            bindingNavigator1.BindingSource = bindingSource1;
            dataGridView1.DataSource = bindingSource1;
        }
        private void toolStripbtnLuu_Click(object sender, EventArgs e)
        {
            bindingNavigatorPositionItem.Focus();
            if (dmto_ctr.save() == true)
                MessageBox.Show(this, "Bạn đã lưu những thay đổi thành công!", "xác nhận", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
        }
        private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
        {
          dmto_ctr.obj_Dmto.Mato = dataGridView1.CurrentRow.Cells[0].Value.ToString();
          dmto_ctr.obj_Dmto.Tento = dataGridView1.CurrentRow.Cells[1].Value.ToString();
          dmto_ctr.AddTo();
          bindingNavigator1.BindingSource.MoveLast();
        }

    }
}
